<?php

    // 设置字符编码
    header('content-type:text/html;charset=utf-8');

    $link = mysqli_connect('localhost','root','root','cd-h52205');

    // 接收传递过来的数据
    $user = $_POST['name'];
    $pass = $_POST['pas'];


    $sql = "select * from name where neme='$user' and pwd='$pass'";

    $data = mysqli_query($link, $sql);

    $res = mysqli_fetch_all($data, MYSQLI_ASSOC);

    if(count($res)){
        echo json_encode(array('code'=>200, 'body'=>array(
            'msg'=>'登录成功'
        )));
    }else{
        echo json_encode(array('code'=>404, 'body'=>array(
            'msg'=>'用户名密码错误，请重新输入或点击注册'
        )));
    }

?>